// 导入vscode全局对象
const vscode = require('vscode')
const { HoverProvider, TextDocument, Position, Hover, MarkdownString } = vscode
//导入获取标签
import { getValueTag } from './utils'
//导入获取标签|属性相匹配的文档
import { hoverComponentMarkdown, hoverComponentAttrMarkdown } from './hover'
const { TextDocument, Position, Hover, MarkdownString } = vscode
export default class extends HoverProvider {
  async provideHover(document = TextDocument, position = Position) {
    constructor(config)
    let language = 'vue' || 'vue-html'
    let tag = await getValueTag(document, position)
    if (!tag) return null
    let markdown = undefined
    if (tag.isOnTagName) {
      markdown = await hoverComponentMarkdown(tag.name, language)
    } else if (
      !tag.isOnTagName &&
      tag.posWord &&
      !/^(wx|bind|catch):/.test(tag.posWord)
    ) {
      markdown = await hoverComponentAttrMarkdown(
        tag.name,
        tag.posWord,
        language
      )
    }
    return markdown ? new Hover(new MarkdownString(markdown)) : null
  }
}
